﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SISGEZATBZVisual.BusinessEntities;

namespace SISGEZATBZVisual.Repository.Mapping
{
    public class EgresoMap:EntityTypeConfiguration<Egreso>
    {
        public EgresoMap()
        {
            this.HasKey(r => r.Id);

            //propiedades
            this.Property(r => r.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(r => r.TipoComprobante)
                .HasMaxLength(70)
                .IsRequired();

            this.Property(r => r.NroComprobante)
               .IsRequired();

            this.Property(c => c.Proveedor)
            .HasMaxLength(255)
            .IsRequired();

            this.Property(c => c.FechaEgreso)
            .IsRequired();

            this.Property(c => c.Importe)
            .IsRequired();

            this.Property(c => c.DescripcionEgreso)
            .HasMaxLength(255)
            .IsOptional();


            //table
            this.ToTable("Egreso");

            //Relaciones
            this.HasRequired(r => r.AñoAcademico)
                .WithMany()
                .HasForeignKey(r => r.IdAñoAcademico)
                .WillCascadeOnDelete(false);
        }
    }
}
